<script setup lang="ts">
import type { DefaultTheme } from 'vitepress/theme';
import { inject, onMounted, Ref, ref } from 'vue';
import VPButton from './VPButton.vue';
import VPImage from './VPImage.vue';

export interface HeroAction {
    theme?: 'brand' | 'alt';
    text: string;
    link: string;
}

defineProps<{
    name?: string;
    text: string;
    tagline?: string;
    image?: DefaultTheme.ThemeableImage;
    actions?: HeroAction[];
}>();

let floatIcon = ref(false);
onMounted(() => {
    setTimeout(() => {
        floatIcon.value = true;
    }, 2000);
});

const curTheme = inject('current-theme') as Ref<string>;
</script>

<template>
    <div class="VPHero farris-doc-banner-wrapper" :class="{ 'has-image': image }" style="padding: 0">
        <div class="farris-doc-banner">
            <div class="banner-content">
                <div class="banner-left-top"><span :class="floatIcon ? 'banner-scene' : ''">表格</span></div>
                <div class="banner-left-bottom"><span :class="floatIcon ? 'banner-scene' : ''">色彩</span></div>
                <div class="banner-right-top"><span :class="floatIcon ? 'banner-scene' : ''">模版</span></div>
                <div class="banner-right-bottom"><span :class="floatIcon ? 'banner-scene' : ''">图标</span></div>
            </div>

            <div class="banner-text"></div>
            <div class="bg-left-top"></div>
            <div class="bg"></div>
        </div>
        <div class="farris-doc-character-wrapper">
            <!--图标不新暂时隐藏-->
            <!-- <div class="farris-doc-character">
                <div class="farris-doc-character--row">
                    <div class="character-item character-001">
                        <div class="character-icon"></div>
                        <div class="content">
                            <h2>快速</h2>
                            <h4><span>F</span>ast</h4>
                        </div>
                        <span class="bg">Fast</span>
                    </div>
                    <div class="character-item character-002">
                        <div class="character-icon"></div>
                        <div class="content">
                            <h2>可靠</h2>
                            <h4><span>R</span>eliable</h4>
                        </div>
                        <span class="bg">Reliable</span>
                    </div>
                    <div class="character-item character-003">
                        <div class="character-icon"></div>
                        <div class="content">
                            <h2>响应</h2>
                            <h4><span>R</span>esponsive</h4>
                        </div>
                        <span class="bg">Responsive</span>
                    </div>
                    <div class="character-item character-004">
                        <div class="character-icon"></div>
                        <div class="content">
                            <h2>直觉</h2>
                            <h4><span>I</span>ntuitive</h4>
                        </div>
                        <span class="bg">Intuitive</span>
                    </div>
                    <div class="character-item character-005">
                        <div class="character-icon"></div>
                        <div class="content">
                            <h2>智能</h2>
                            <h4><span>S</span>mart</h4>
                        </div>
                        <span class="bg">Smart</span>
                    </div>
                </div>
            </div> -->
            <div class="farris-doc-character--bottom-bg">
                <img src="/assets/bg-character-top.png" class="img-block" style="max-height:114px;" v-if="curTheme != 'dark'" />
                <img src="/assets/bg-character-top-dark.png" class="img-block" style="max-height:114px;"  v-if="curTheme == 'dark'" />
            </div>
        </div>
        <!-- <div class="container">
      <div class="main">
        <h1 v-if="name" class="name">
          <span class="clip">{{ name }}</span>
        </h1>
        <p v-if="text" class="text">{{ text }}</p>
        <p v-if="tagline" class="tagline">{{ tagline }}</p>

        <div v-if="actions" class="actions">
          <div v-for="action in actions" :key="action.link" class="action">
            <VPButton
              tag="a"
              size="medium"
              :theme="action.theme"
              :text="action.text"
              :href="action.link"
            />
          </div>
        </div>
      </div>

      <div v-if="image" class="image">
        <div class="image-container">
          <div class="image-bg" />
          <VPImage class="image-src" :image="image" />
        </div>
      </div>
    </div> -->
    </div>
</template>

<style scoped>
/**Banner */
.farris-doc-banner {
    height: 600px;
    position: relative;
}
.farris-doc-banner-wrapper {
    position: relative;
}
.farris-doc-banner-wrapper .banner-text {
    position: absolute;
    width: 717px;
    z-index: 30;
    top: 50%;
    left: 50%;
    margin-top: -100px;
    margin-left: -360px;
    height: 203px;
    background-repeat: no-repeat;
    background-image: var(--banner-text);
}
/**底纹背景 */
.farris-doc-banner-wrapper::before {
    content: '';
    opacity: 0.34;
    position: absolute;
    z-index: 1;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    background-image: linear-gradient(-51deg, rgba(71, 158, 255, 0.35) 0%, #2a87ff 100%);
}

.farris-doc-banner .bg,
.farris-doc-banner .bg-left-top,
.farris-doc-banner .bg-right-top {
    background-repeat: no-repeat;
    position: absolute;
    top: 0;
    bottom: 0;
}
.farris-doc-banner .bg {
    z-index: 10;
    left: 0;
    right: 0;
    background-image: var(--banner-bg);
    background-position: center;
}
.farris-doc-banner .bg-left-top {
    left: 0;
    z-index: 20;
    width: 50%;
    background-image: url(/assets/banner-bg-left-top.png);
    background-position: 0 0;
}
.dark .farris-doc-banner .bg-left-top {
    opacity: 0.25;
}

/**场景图 */
.banner-content {
    position: relative;
    padding: 90px 0 0;
    margin: 0 auto 0;
    height: 600px;
    z-index: 50;
    background-repeat: no-repeat;
    background-position: right top;
    background-image: url(/assets/banner-bg-right-top.png);
    max-width: var(--vp-layout-max-width);
}
.banner-content .banner-scene {
    transform: scale(1);
    opacity: 1;
    animation-iteration-count: infinite;
    animation-duration: 2s;
    animation-name: bannericonfloat;
}

.banner-right-top .banner-scene {
    animation-delay: 1s;
}
.banner-left-bottom .banner-scene {
    animation-delay: 1.5s;
}
.banner-content span {
    display: block;
    overflow: hidden;
    color: transparent;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background-repeat: no-repeat;
    animation-duration: 0.5s;
    animation-delay: 0.5s;
    animation-name: bannershowicons;
    animation-fill-mode: both;
    transform-origin: center center;
}

.banner-left-top {
    width: 336px;
    height: 113px;
    position: absolute;
    left: 0;
    top: 90px;
    background-image: var(--banner-left-top-001);
}
.banner-left-top span {
    height: 58px;

    background-image: var(--banner-left-top-002);
}

.banner-left-bottom {
    width: 336px;
    height: 113px;
    position: absolute;
    bottom: 0;
    left: 0;
    background-image: var(--banner-left-bottom-001);
}
.banner-left-bottom span {
    position: absolute;
    top: -50px;
    left: 0;
    height: 117px;
    width: 180px;
    background-image: var(--banner-left-bottom-002);
}
.banner-right-top {
    height: 200px;
    width: 370px;
    top: 50px;
    position: absolute;
    right: 0px;
}

.banner-right-top span {
    height: 200px;
    background-image: var(--banner-right-top-002);
}

.banner-right-bottom {
    width: 250px;
    height: 193px;
    bottom: 0px;
    position: absolute;
    right: 0px;
    background-image: var(--banner-right-bottom-001);
}

.banner-right-bottom span {
    height: 83px;
    width: 143px;
    top:30%;
    background-image: var(--banner-right-bottom-002);
}

/**五个特性 */
.farris-doc-character-wrapper {
    position:relative;
}
.farris-doc-character {
    margin: 0 auto;
    position: absolute;
    bottom: 40%;
    left: 0;
    right: 0;
    max-width: var(--vp-layout-max-width);
}
.farris-doc-character--row {
    display: flex;
    margin: 0 calc(-1 * var(--character-distance-outer));
}
.character-item {
    border-radius: 16px;
    margin: 0 var(--character-distance-outer);
    padding: 10px 0;
    flex: 1 1 0;
    box-shadow: 0px 0px 15px 0px rgba(2, 28, 58, 0.15);
    font-size: 20px;
    color: var(--character-title-text);
    line-height: 28px;
    display: flex;
    flex-direction: var(--flex-direction);
    align-items: center;
    height: 130px;
    position: relative;
    z-index: 20;
    overflow: hidden;
}
.character-item .character-icon,
.character-item .content {
    position: relative;
    z-index: 20;
}
.character-item .content {
    scale: var(--scale-size);
}

.character-item .character-icon {
    width: 40%;
    height: var(--character-icon-height);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
    background-image: url('/assets/character-icon-001.png');
}
.character-item .bg {
    position: absolute;
    z-index: 1;
    top: 0px;
    left: 0px;
    right: 0;
    bottom: 0;
    padding: 26px 0 0 0;
    overflow: hidden;
    font-size: 50px;
    color: var(--character-bg-text);
    opacity: 0.05;
}
.character-item::before {
    content: '';
    position: absolute;
    z-index: 2;
    opacity: 0.5;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 16px;
    backdrop-filter: blur(3px);
    background-image: linear-gradient(139deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
}
.dark .character-item::before {
    background-image: linear-gradient(139deg, rgba(48, 81, 123, 0.33) 0%, #4c4c6e 100%);
}
.farris-doc-character--bottom-bg {
    position: relative;
    z-index: 5;
}
.character-item h4 span {
    color: #2a87ff;
}
.character-item h2 {
    font-size: 24px;
    line-height: 33px;
    margin-bottom: 5px;
}
.VPHero {
    margin-top: calc(var(--vp-nav-height) * -1);
    padding: calc(var(--vp-nav-height) + 48px) 24px 48px;
}

@media (min-width: 640px) {
    .VPHero {
        /* padding: calc(var(--vp-nav-height) + 80px) 48px 64px; */
    }
}

@media (min-width: 960px) {
    .VPHero {
        /* padding: calc(var(--vp-nav-height) + 80px) 64px 64px; */
    }
}

.container {
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    max-width: 1152px;
}

@media (min-width: 960px) {
    .container {
        flex-direction: row;
    }
}

.main {
    position: relative;
    z-index: 10;
    order: 2;
    flex-grow: 1;
    flex-shrink: 0;
}

.VPHero.has-image .container {
    text-align: center;
}

@media (min-width: 960px) {
    .VPHero.has-image .container {
        text-align: left;
    }
}

@media (min-width: 960px) {
    .main {
        order: 1;
        width: calc((100% / 3) * 2);
    }

    .VPHero.has-image .main {
        max-width: 592px;
    }
}

.name,
.text {
    max-width: 392px;
    letter-spacing: -0.4px;
    line-height: 40px;
    font-size: 32px;
    font-weight: 700;
    white-space: pre-wrap;
}

.VPHero.has-image .name,
.VPHero.has-image .text {
    margin: 0 auto;
}

.name {
    color: var(--vp-home-hero-name-color);
}

.clip {
    background: var(--vp-home-hero-name-background);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: var(--vp-home-hero-name-color);
}

@media (min-width: 640px) {
    .name,
    .text {
        max-width: 576px;
        line-height: 56px;
        font-size: 48px;
    }
}

@media (min-width: 960px) {
    .name,
    .text {
        line-height: 64px;
        font-size: 56px;
    }

    .VPHero.has-image .name,
    .VPHero.has-image .text {
        margin: 0;
    }
}

.tagline {
    padding-top: 8px;
    max-width: 392px;
    line-height: 28px;
    font-size: 18px;
    font-weight: 500;
    white-space: pre-wrap;
    color: var(--vp-c-text-2);
}

.VPHero.has-image .tagline {
    margin: 0 auto;
}

@media (min-width: 640px) {
    .tagline {
        padding-top: 12px;
        max-width: 576px;
        line-height: 32px;
        font-size: 20px;
    }
}

@media (min-width: 960px) {
    .tagline {
        line-height: 36px;
        font-size: 24px;
        max-width: 960px;
        padding-top: 0;
    }

    .VPHero.has-image .tagline {
        margin: 0;
    }
}

.actions {
    display: flex;
    flex-wrap: wrap;
    margin: -6px;
    padding-top: 24px;
}

.VPHero.has-image .actions {
    justify-content: center;
}

@media (min-width: 640px) {
    .actions {
        /* padding-top: 32px; */
    }
}

@media (min-width: 960px) {
    .VPHero.has-image .actions {
        justify-content: flex-start;
    }
}

.action {
    flex-shrink: 0;
    padding: 6px;
}

.image {
    order: 1;
    margin: -76px -24px -48px;
}

@media (min-width: 640px) {
    .image {
        margin: -108px -24px -48px;
    }
}

@media (min-width: 960px) {
    .image {
        flex-grow: 1;
        order: 2;
        margin: 0;
        min-height: 100%;
    }
}

.image-container {
    position: relative;
    margin: 0 auto;
    width: 320px;
    height: 320px;
}

@media (min-width: 640px) {
    .image-container {
        width: 392px;
        height: 392px;
    }
}

@media (min-width: 960px) {
    .image-container {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        height: 100%;
        transform: translate(-32px, -32px);
    }
}

.image-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    width: 192px;
    height: 192px;
    background-image: var(--vp-home-hero-image-background-image);
    filter: var(--vp-home-hero-image-filter);
    transform: translate(-50%, -50%);
}

@media (min-width: 640px) {
    .image-bg {
        width: 256px;
        height: 256px;
    }
}

@media (min-width: 960px) {
    .image-bg {
        width: 320px;
        height: 320px;
    }
}

:deep(.image-src) {
    position: absolute;
    top: 50%;
    left: 50%;
    max-width: 192px;
    transform: translate(-50%, -50%);
}

@media (min-width: 640px) {
    :deep(.image-src) {
        max-width: 256px;
    }
}

@media (min-width: 960px) {
    :deep(.image-src) {
        max-width: 320px;
    }
}
</style>
